package ejemplo;

import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class GreetingController {

	@RequestMapping("/greeting")
	public @ResponseBody
	Clasee greeting(
			@RequestParam(value = "name", required = false, defaultValue = "World") String name) {
		Clasee clase = new Clasee();
		clase.setAbout("sobre");
		clase.setName("nombre");
		return clase;
	}

	@RequestMapping(value = "/json", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE)
	public @ResponseBody
	Clasee jsonMethod(@RequestBody Clasee json) {
		Clasee clase = new Clasee();
		clase.setAbout("sobre");
		clase.setName("nombre");
		return clase;
	}

	@RequestMapping("/greeting2")
	public @ResponseBody
	String greeting2(
			@RequestParam(value = "name", required = false, defaultValue = "World") String name) {
		return "greeting2";
	}

	@RequestMapping(value = "/", method = RequestMethod.GET)
	public @ResponseBody
	String index() {
		return "index";
	}
}